<cfcomponent displayname="ESAPI" hint="ESAPI locator class to make it easy to get a concrete implementation of the various ESAPI classes." output="false">

  <!-------------------------------------------------------------------------
     Default location for properties. You can change it here or by calling
     the setResourceDirectory on the SecurityConfigutation component.
   ------------------------------------------------------------------------->
  <cfset defaultResourceDirectory = expandPath('/cfesapi/resources') />


  <cffunction name="init" access="public" returntype="ESAPI" output="false" hint="Instantiates the object and loads it with the security services">
    <cfset var loader = createObject('component' , 'ClassLoader').init() />
    <cfscript>
      // set default resource directory. will fall back on other locations if missing
      var  sys = createObject('component', 'SecurityConfiguration').setResourceDirectory(defaultResourceDirectory & '/.esapi');
      var esapi = loader.create("org.owasp.esapi.ESAPI");
      configureLogger(loader,esapi);
    </cfscript>
		<cfreturn this />
	</cffunction>


<cffunction name="configureLogger" access="private" returntype="void">
  <cfargument name="loader" />
   <cfargument name="esapi" />
    <cfscript>
     var log4j = loader.create("org.owasp.esapi.reference.Log4JLogFactory");
  	 //set the path to config
		 var log4jConfigPath = "#defaultResourceDirectory#/log4j.xml";//default
		 var  domConfig = createObject('java' ,'org.apache.log4j.xml.DOMConfigurator');
		 esapi.setLogFactory(log4j);
		 //configure the path
		 domConfig.configure(log4jConfigPath);
     //get the logger
     variables.logger = log4j.getLogger('cfesapi');
   </cfscript>
</cffunction>



  <!----------------------------------------------------------------------------
                               Default Authenticator
  ----------------------------------------------------------------------------->
	<cffunction name="authenticator" access="public" returntype="cfesapi.org.owasp.esapi.Authenticator" output="false">
		<cfset var authenticator = createObject("component","Authenticator").init(this) />
    <cfreturn authenticator />
	</cffunction>


	<cffunction name="setAuthenticator" access="public" returntype="void" output="false">
		<cfargument name="Authenticator" type="cfesapi.org.owasp.esapi.Authenticator" />
    <cfset variables.authenticator = arguments.Authenticator />
	</cffunction>




  <!----------------------------------------------------------------------------
                               Default Encoder
  ----------------------------------------------------------------------------->

  <cffunction name="encoder" access="public" returntype="cfesapi.org.owasp.esapi.Encoder" output="false">
	  <cfset var encoder = createObject("component","cfesapi.org.owasp.esapi.Encoder").init() />
    <cfreturn encoder />
	</cffunction>

	<cffunction name="setEncoder" access="public" returntype="void" output="false">
		<cfargument name="Encoder" type="cfesapi.org.owasp.esapi.Validator" />
    <cfset variables.encoder = arguments.Encoder />
	</cffunction>




  <!----------------------------------------------------------------------------
                               Default Encryptor
  ----------------------------------------------------------------------------->
	<cffunction name="encryptor" access="public" returntype="cfesapi.org.owasp.esapi.Encryptor" output="false">
	  <cfreturn variables.encryptor />
	</cffunction>

	<cffunction name="setEncryptor" access="public" returntype="void" output="false">
		<cfargument name="Encryptor" type="cfesapi.org.owasp.esapi.Encryptor" />
    <cfset variables.encryptor = arguments.encryptor />
	</cffunction>





  <!----------------------------------------------------------------------------
                               Default Executor
  ----------------------------------------------------------------------------->
	<cffunction name="executor" access="public" returntype="cfesapi.org.owasp.esapi.Executor" output="false">

	</cffunction>

	<cffunction name="setExecutor" access="public" returntype="void" output="false">
		<cfargument name="Executor" type="cfesapi.org.owasp.esapi.Executor" />
	</cffunction>




  <!----------------------------------------------------------------------------
                               Default HttpUtilities
  ----------------------------------------------------------------------------->
	<cffunction name="httpUtilities" access="public" returntype="cfesapi.org.owasp.esapi.HTTPUtilities" output="false">

	</cffunction>

	<cffunction name="setHTTPUtilities" access="public" returntype="void" output="false">
		<cfargument name="HTTPUtilities" type="cfesapi.org.owasp.esapi.HTTPUtilities" />
	</cffunction>



  <!----------------------------------------------------------------------------
                               Default Logger
  ----------------------------------------------------------------------------->

	<cffunction name="logger" access="public" returntype="cfesapi.org.owasp.esapi.Logger" output="false">
		<cfargument name="name" required="false" type="string" default="cfesapi" hint="The name of the type of logger" />
		<cfset var logger = createObject('component','Logger').init(variables.logger) />
    <cfreturn logger />
	</cffunction>




  <!----------------------------------------------------------------------------
                               Default SecurityConfiguration
  ----------------------------------------------------------------------------->
	<cffunction name="securityConfiguration" access="public" returntype="cfesapi.org.owasp.esapi.SecurityConfiguration" output="false">
		<cfset var securityConfiguration = createObject("component","SecurityConfiguration").init() />
	  <cfreturn securityConfiguration />
	</cffunction>

	<cffunction name="setSecurityConfiguration" access="public" returntype="void" output="false">
		<cfargument name="SecurityConfiguration" type="cfesapi.org.owasp.esapi.SecurityConfiguration" />
    <cfset variables.securityConfiguration = arguments.SecurityConfiguration  />
	</cffunction>





  <!----------------------------------------------------------------------------
                               Default Validtor
  ----------------------------------------------------------------------------->
	<cffunction name="validator" access="public" returntype="cfesapi.org.owasp.esapi.Validator" output="false">
    <cfset var validator = createObject("component","Validator").init() />
	  <cfreturn validator />
	</cffunction>

	<cffunction name="setValidator" access="public" returntype="void" output="false">
		<cfargument name="Validator" type="cfesapi.org.owasp.esapi.Validator" />
	</cffunction>





  <!----------------------------------------------------------------------------
                                   ???
  ----------------------------------------------------------------------------->
	<cffunction name="sessionFacade" access="public" returntype="cfesapi.org.owasp.esapi.sessionFacade" output="false">
		 <cfset var sessionFacade = createObject("component","SessionFacade").init() />
	   <cfreturn sessionFacade />
	</cffunction>



</cfcomponent>